<template>
  <div class="video body">
    <div class="页眉">
    </div>

    <!--分栏-->
    <el-row :gutter="16" type="flex" justify="center">
      <!--菜单栏-->
      <el-col :span="4">
        <div class="文本框" style="height: 900px;">
          <el-menu  router>
            <el-menu-item index="/CreationCenter" >
              <div class="文本">
                <i class="el-icon-menu"></i>
                首页
              </div>
            </el-menu-item>
            <el-submenu index="001">
              <template slot="title">
                <div class="文本">
                  <i class="el-icon-edit-outline"></i>
                  创作
                </div>
              </template>
              <el-menu-item index="/CreationCenter/SendArticle">发布文章</el-menu-item>
              <el-menu-item index="/CreationCenter/SendVideo">发布视频</el-menu-item>
              <el-menu-item index="/CreationCenter/SendReport">发布研报</el-menu-item>
              <el-menu-item index="/CreationCenter/SendTinyArticle">发布富微条</el-menu-item>
            </el-submenu>
            <el-menu-item index="/CreationCenter/ManageArticle">
              <div class="文本">
                <i class="el-icon-reading"></i>
                作品管理
              </div>
            </el-menu-item>
            <el-submenu index="002">
              <template slot="title">
                <div class="文本">
                  <i class="el-icon-view"></i>
                  互动管理
                </div>
              </template>
              <el-menu-item index="/CreationCenter/ManageFollow">关注管理</el-menu-item>
              <el-menu-item index="/CreationCenter/ManageComment">评论管理</el-menu-item>
              <el-menu-item index="/CreationCenter/ManagePM">私信管理</el-menu-item>
            </el-submenu>
            <el-submenu index="003">
              <template slot="title">
                <div class="文本">
                  <i class="el-icon-document"></i>
                  数据分析
                </div>
              </template>
              <el-menu-item index="/CreationCenter/DataArticle">作品数据</el-menu-item>
              <el-menu-item index="/CreationCenter/DataFans">粉丝数据</el-menu-item>
              <el-menu-item index="/CreationCenter/DataProfit">收益数据</el-menu-item>
            </el-submenu>
            <el-menu-item index="/CreationCenter/Option">
              <div class="文本">
                <i class="el-icon-setting"></i>
                设置
              </div>
            </el-menu-item>
          </el-menu>
        </div>
      </el-col>
      <!--正文栏-->
      <el-col :span="14">
        <div class="grid-content">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/CreationCenter' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>发布研报</el-breadcrumb-item>
          </el-breadcrumb>
          <br/>

          <el-input
              type="text"
              placeholder="标题"
              border="0"
              v-model="text"
              maxlength="30"
              show-word-limit>
          </el-input>
          <el-divider></el-divider>
          <el-row type="flex" justify="center">
            <el-upload
                class="upload-demo"
                drag
                action="http://39.102.76.217:8100/article/uploadfile"
                multiple
                :file-list="fileList"
                :limit="1"
                :on-success="handleSuccess"
                :on-exceed="handleExceed">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text"><em>点击上传</em></div>
              <br/>
              <div class="el-upload__tip 居中">提示：只支持上传pdf格式</div>
            </el-upload>
          </el-row>


          <br/>
          <br/>
          <br/>
          <div class="居中">
            <el-button>预览</el-button>
            <el-button type="primary" @click="uploadFile">发布</el-button>
          </div>
        </div>
      </el-col>
    </el-row>


    <div class="页眉">
    </div>
  </div>
</template>

<style>
.el-textarea__inner {
  border-radius: 0px;
  font-size: 16px;
  resize: none;
}

</style>


<script>
export default {
  data() {
    return {
      textarea: '',
      fileList:[],
      text: '',
      radio: 0,
      radio_2: 0,
      content: '',
      editorOption: {
        placeholder: ''
      },
      uploadArticleArgs: {
        idUser: window.sessionStorage.getItem("idUser"),
        articleTitle:"测试用的第一篇文章",
        articleAbstract:"测试用的第一篇文章的摘要",
        articleUploadUrl:"222.11.1123.1",
        articleUpdateUrl:"222.11.1123.1",
        articleAuthority:"0",
        articleType:"嘿嘿",
        articleStatus:"1",
        articleContent:"",
        articleCover:""
      }
    }
  },
  methods: {
    handleSuccess(res) {
      this.uploadArticleArgs.articleContent= res.fileUrl
      console.log(res)
      console.log(this.uploadArticleArgs)
    },
    handleExceed(files, fileList) {
      this.$message.warning(`最多只能上传一个文件`);
    },
    async uploadFile() {
      this.uploadArticleArgs.articleTitle = this.text
      const {data: res} = await this.$http.post("http://39.102.77.65:8081/article/upload", this.uploadArticleArgs);
      this.$message({
        message: '发布成功！',
        type: 'success'
      });
      this.$router.push('/CreationCenter');
      console.log(res)
    },

  }
}
</script>